home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / pgp20src.zip / FILEIO.H < prev    next >
C/C++ Source or Header  |  1992-08-05  |  4KB  |  115 lines

  1. #define DISKBUFSIZE 4096    /* Size of I/O buffers */
  2.  
  3. #ifndef SEEK_SET
  4. #define SEEK_SET 0
  5. #define    SEEK_CUR 1
  6. #define SEEK_END 2
  7. #endif
  8.  
  9.  
  10. #define    TMP_WIPE        1
  11. #define    TMP_TMPDIR        4
  12.  
  13. #define equal_buffers(buf1,buf2,count)    !memcmp( buf1, buf2, count )
  14.  
  15. /* This macro is for burning sensitive data (byte arrays only) on stack.
  16.    Many of the file I/O routines use it for zapping buffers */
  17. #define burn(x) fill0(x,sizeof(x))
  18.  
  19. /* Returns TRUE iff file is can be opened for reading. */
  20. boolean file_exists(char *filename);
  21.  
  22. /* Returns TRUE iff file can be opened for writing. Does not harm file! */
  23. boolean file_ok_write(char *filename);
  24.  
  25. /* Completely overwrite and erase file, so that no sensitive information is
  26.    left on the disk */
  27. int wipeout(FILE *f);
  28.  
  29. /* Completely overwrite and erase file of given name, so that no sensitive
  30.    information is left on the disk */
  31. int wipefile(char *filename);
  32.  
  33. /* Return the after-slash part of the filename */
  34. char    *file_tail (char *filename);
  35. /* Returns TRUE if user left off file extension, allowing default */
  36. boolean no_extension(char *filename);
  37.  
  38. /* Deletes trailing ".xxx" file extension after the period */
  39. void drop_extension(char *filename);
  40.  
  41. /* Append filename extension if there isn't one already */
  42. void default_extension(char *filename, char *extension);
  43.  
  44. /* Change the filename extension */
  45. void force_extension(char *filename, char *extension);
  46.  
  47. /* Get yes/no answer from user, returns TRUE for yes, FALSE for no */
  48. boolean getyesno(char default_answer);
  49.  
  50. /* If luser consents to it, change the filename extension */
  51. void maybe_force_extension(char *filename, char *extension);
  52.  
  53. /* Builds a filename with a complete path specifier from the environmental
  54.    variable PGPPATH */
  55. char *buildfilename(char *result, char *fname);
  56.  
  57. /* Build a path for fileName based on origPath */
  58. int build_path(char *path, char *fileName, char *origPath);
  59.  
  60. /* Convert filename to canonical form, with slashes as separators */
  61. void file_to_canon(char *filename);
  62.  
  63. /* Convert filename from canonical to local form */
  64. void file_from_canon(char *filename);
  65.  
  66. /* Copy file f to file g, for longcount bytes */
  67. int copyfile(FILE *f, FILE *g, word32 longcount);
  68.  
  69. /* Copy file f to file g, for longcount bytes, positioning f at fpos */
  70. int copyfilepos (FILE *f, FILE *g, word32 longcount, word32 fpos);
  71.  
  72. /* Copy file f to file g, for longcount bytes.  Convert to canonical form
  73.    as we go.  f is open in text mode.  Canonical form uses crlf's as line
  74.    separators */
  75. int copyfile_to_canon (FILE *f, FILE *g, word32 longcount);
  76.  
  77. /* Copy file f to file g, for longcount bytes.  Convert from canonical to
  78.    local form as we go.  g is open in text mode.  Canonical form uses crlf's
  79.    as line separators */
  80. int copyfile_from_canon (FILE *f, FILE *g, word32 longcount);
  81.  
  82. /* Copy srcFile to destFile */
  83. int copyfiles_by_name(char *srcFile, char *destFile);
  84.  
  85. /* Copy srcFile to destFile, converting to canonical text form */
  86. int make_canonical(char *srcFile, char *destFile);
  87.  
  88. /* Like rename() but will try to copy the file if the rename fails. This is
  89.    because under OS's with multiple physical volumes if the source and
  90.    destination are on different volumes the rename will fail */
  91. int rename2(char *srcFile, char *destFile);
  92.  
  93. /* Read the data from stdin to the phantom input file */
  94. int readPhantomInput(char *filename);
  95.  
  96. /* Write the data from the phantom output file to stdout */
  97. void writePhantomOutput(char *filename);
  98.  
  99. /* Return the size from the current position of file f to the end */
  100. word32 fsize (FILE *f);
  101.  
  102. /* Return TRUE if file filename is a text file */
  103. int is_text_file (char *filename);
  104.  
  105. FILE *fopenbin(char *, char *);
  106. FILE *fopentxt(char *, char *);
  107.  
  108. void *xmalloc(unsigned);
  109.  
  110. char *tempfile(int);
  111. void rmtemp(char *);
  112. char *savetemp(char *, char *);
  113. void cleanup_tmpf(void);
  114. int savetempbak(char *, char *);
  115.